﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CPS1
{
    // NUDY: Patrz VaultSignal
    class ImpulseSignal : Signal
    {
        public Double n1; // numer pierwszej próbki
        public Double ns; // numer próbki skoku
        private int counter;

        public ImpulseSignal(Double A, Double n1, Double ns, Double d, Double f, String name) 
        {
            this.A = A;
            this.t1 = Math.Round(n1 * f, 6); // przeliczamy numer pierwszej próbki na jej czas
            this.ns = ns; // przeliczamy numer próbki skoku na czas
            this.d = d;
            this.f = f;
            this.name = name;
            this.periodical = false;
            this.discrete = true;
            this.counter = 0;

            int amount = (int) Math.Ceiling(d * f);
            this.calculatedValues = new Double[amount, 2];
        }

        override public Double value(Double t)
        {
            // dla odmiany: wzorek z instrukcji
            if(this.counter == this.ns){
                this.counter++;
                return this.A;
            }else{
                this.counter++;
                return 0.0;
            }
        }

        public override Signal copy()
        {
            ImpulseSignal copied = new ImpulseSignal(this.A, this.t1, this.ns, this.d, this.f, this.name);
            copied.calculateSignal();
            return copied;
        }
    }
}
